package com.vg.zuul.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

@Component
@Primary
public class SwaggerConfig implements SwaggerResourcesProvider {

    @Override
    public List<SwaggerResource> get() {

        List resources = new ArrayList<>();

        /**
         * user ---> 这个就是个模块的名字，可以随便起
         * /u/v2/api-docs ---> u就是application.yml配置的路由路径，后面的/v2/api-docs固定写法
         * 新加一个API模块在此添加一个resource
         */
        resources.add(swaggerResource("平台管理系统api", "/t/v2/api-docs", "1.0"));
        resources.add(swaggerResource("首页api", "/h/v2/api-docs", "1.0"));
        resources.add(swaggerResource("商家api", "/m/v2/api-docs", "1.0"));
        resources.add(swaggerResource("门店api", "/s/v2/api-docs", "1.0"));
        resources.add(swaggerResource("用户api", "/u/v2/api-docs", "1.0"));
        resources.add(swaggerResource("优惠券活动api", "/a/v2/api-docs", "1.0"));
        resources.add(swaggerResource("购物车api", "/shopping/v2/api-docs", "1.0"));
        resources.add(swaggerResource("分类api", "/c/v2/api-docs", "1.0"));


        return resources;
    }

    private Object swaggerResource(String name, String location, String version) {

        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}